<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
    <%@include file="/resources/datepicker/datepicker.jsp"%>
    <title><spring:message code="title.claim"/></title>
    <script type="text/javascript">
        var operateDialog;
        var message =parent.message;
        $(function(){
            $("#file").change(function(){
                var photo = $(this).val();
                var right = true;
                if (!photo) {
                    right = false;
                }
                var ps = photo.split(".");
                if (ps.length < 2) {
                    right = false;
                } else {
                    var format = ps[ps.length - 1].toLowerCase();
                    if (format!="png") {
                        right = false;
                    } else {
                        $(this).parents("form:first").submit();
                        imonJYRH.showZone;
                    }
                }
                if (!right) {
                    $.messager.alert('<spring:message code='msg.tip'/>','<spring:message code='msg.picture.format'/>');
                    return false;
                }
            });

            cs9_();
        });
        function cs9_(){
            if($('#typeDate').is(':checked')){
                $("#td_cs9").html('<input id="cs9_date" type="text" name="cs9" onFocus="WdatePicker({isShowWeek:true})" class="field Wdate"/>');
            }else if($('#typeNa').is(':checked')){
                $("#td_cs9").html('<input id="cs9_Na" type="text" name="cs9" value="Na" readonly/>');

            }
        }
        function OnUploadCompleted(reMsg){
            reMsg = eval('(' + reMsg + ')');
            if(imonJYRH.isBlank(reMsg)){
                $.messager.alert('<spring:message code='msg.picture.error'/>');
                return;
            }
            if(reMsg.success){
                imonJYRH.hideZone;
                var uri = reMsg.obj;
                $("#picture").val(uri);
                //$("#fileImg").attr("src","${path}"+uri+"_100X100"+imonJYRH.getImageType(uri));
                $("#fileImg").attr("src","${path}"+uri);
            }
        }
        /**把字段组合到一起*/
        function combine(){
            $("#code").val('SCR-'+$("#code_workshop").val()+'-'+$("#code_productType").val()+'-${claimVo.year}-');
            $("#notQualifiedReportCode").val(
                    $("#notQualifiedReportCode_reportCode").val()+'-'+
                            $("#notQualifiedReportCode_workshop").val()+'-'+
                            $("#notQualifiedReportCode_productType").val()+
                            '-${claimVo.year}-'+
                            $("#notQualifiedReportCode_flowCode").val()
            );
        }
        function validate(){
            $(".tableForm").each(function(){
                var isV=$(this).form("validate");
                if(!isV) return false;
            });
            return true;
        }
        function save_(){
            combine();
//            if(!validate())return;
            var isV=$(".tableForm").form("validate");
            if(!isV) return;
            imonJYRH.showZone();
            $.ajax({
                url : '${path}/business/ipic_system/claim_field/ajaxAdd.do',
                data : imonJYRH.serializeObject($(".tableForm *")),
                success : function(reMsg) {
                    if(reMsg.success){
                        parent.returnResult();
                        message.show({ msg : reMsg.msg,title : '<spring:message code='msg.tip'/>',showType:'slide'});
                    }else{
                        if(!imonJYRH.isBlank(reMsg.obj)){
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['obj']);
                        }else{
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['msg']);
                        }
                    }
                    imonJYRH.hideZone();
                }
            });
        }
        function dialogSupplier_(){
            var href = '${path}/basedata/supplier/dialogUI.do';
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.dialog.choose'/>',
                width : 600,
                height : 400
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
        function dialogSupplierReturn(row){
            $("#supplierId").val(row['id']);
            $("#supplierCode").val(row['code']);
            $("#supplierName").val(row['name']);
            $("#supplierMail").val(row['mail']);
            $("#supplierPhone").val(row['phone']);
            $("#supplierLinkman").val(row['linkman']);
            resetPart();
            operateDialog.dialog('close');
        }
        function resetPart(){ //供应商改变时，零件清空
            $("#partId").val("");
            $("#partCode").val("");
            $("#partName").val("");
            $("#drawingCode").val("");
        }
        function dialogPart_(){
            var supplierId=$("#supplierId").val()
            if(imonJYRH.isBlank(supplierId)){
                $.messager.alert('<spring:message code='msg.tip'/>',
                        supplierId+'<spring:message code='msg.please.choose.supplier'/>');
                return;
            }
            var href = '${path}/basedata/part/dialogUI.do?supplierId='+supplierId;
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.dialog.choose'/>',
                width : 550,
                height : 400
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
        function dialogPartReturn(row){
            $("#partId").val(row['id']);
            $("#partCode").val(row['code']);
            $("#partName").val(row['name']);
            $("#drawingCode").val(row['drawingCode']);
            operateDialog.dialog('close');
        }
    </script>
</head>
<body>
<table class="tableForm" width="100%">
    <tr>
        <td align="right"><span style="color:red;">*</span><spring:message code='label.supplier.code'/>:</td>
        <td align="left">
            <input type="hidden" id='supplierId' name="supplierId"/>
            <input type="text" id="supplierCode" onclick="dialogSupplier_();" readonly="true"
                   class="easyui-validatebox" data-options="required:true"/>
        </td>
        <td align="right"><span style="color:red;">*</span><spring:message code='label.claim.reporter.code'/>：</td>
        <td>
            <input type="text" name="reporterCode" class="easyui-validatebox" data-options="required:true"/>
        </td>
    </tr>
    <tr>
        <td align="right"><spring:message code='label.supplier.name'/>:</td>
        <td align="left">
            <input type="text" id="supplierName" disabled/>
        </td>
        <td align="right"><span style="color:red;">*</span><spring:message code='label.claim.reporter.name'/>：</td>
        <td>
            <input type="text" name="reporterName" class="easyui-validatebox" data-options="required:true"/>
        </td>
    </tr>
    <tr>
        <td align="right"><spring:message code='label.supplier.mail'/>:</td>
        <td align="left">
            <input type="text" id="supplierMail" disabled/>
        </td>
        <td align="right"><spring:message code='label.claim.reporter.mail'/>：</td>
        <td>
            <input type="text" name="reporterMail" class="easyui-validatebox" data-options="validType:'email'"/>
        </td>
    </tr>
    <tr>
        <td align="right"><spring:message code='label.supplier.phone'/>:</td>
        <td align="left">
            <input type="text" id="supplierPhone" disabled/>
        </td>
        <td align="right"><spring:message code='label.claim.reporter.phone'/>：</td>
        <td>
            <input type="text" name="reporterPhone" class="easyui-validatebox" data-options="validType:'phone'"/>
        </td>
    </tr>
    <tr>
        <td align="right"><spring:message code='label.supplier.linkman'/>:</td>
        <td align="left">
            <input type="text" id="supplierLinkman" disabled/>
        </td>
        <td align="right"><spring:message code='label.claim.reporter.fax'/>：</td>
        <td>
            <input type="text" name="reporterFax"/>
        </td>
    </tr>
    </tr>
</table>
<hr width="750px"/>
<table class="tableForm" width="100%">
    <tr>
        <td align="right"><span style="color:red;">*</span><spring:message code="label.claim.code"/>：</td>
        <td>
            SCR
            -
            <select style="width:40px;" id="code_workshop">
                <c:forEach var="dict" items="${dictWorkshopList}">
                    <option value="${dict.code}">${dict.name}</option>
                </c:forEach>
            </select>
            -
            <select style="width:36px;" id="code_productType">
                <c:forEach var="dict" items="${dictProductTypeList}">
                    <option value="${dict.code}">${dict.name}</option>
                </c:forEach>
            </select>
            -
            ${claimVo.year}
            -
            <spring:message code="label.claim.flow.code"/>
            <input type="hidden" name="code" id="code"/>
        </td>
        <td align="right"><span style="color:red;">*</span><spring:message code="label.claim.start.date"/>：</td>
        <td>
            <input type="text" value="${claimVo.startDateStr}" name="startDate"
                   onFocus="WdatePicker({isShowWeek:true})" class="field Wdate"/>
        </td>
    </tr>
</table>
<br/>
<fieldset>
    <table class="tableForm" width="100%">
        <tr>
            <td align="right"><span style="color:red;">*</span><spring:message code="label.claim.report.code.not.qualified"/>：</td>
            <td colspan="5">
                <select style="width:50px;" id="notQualifiedReportCode_reportCode">
                    <c:forEach var="dict" items="${dictReportCodeNotQualifiedList}">
                        <option value="${dict.code}">${dict.name}</option>
                    </c:forEach>
                </select>
                -
                <select style="width:40px;" id="notQualifiedReportCode_workshop">
                    <c:forEach var="dict" items="${dictWorkshopList}">
                        <option value="${dict.code}">${dict.name}</option>
                    </c:forEach>
                </select>
                -
                <select style="width:36px;" id="notQualifiedReportCode_productType">
                    <c:forEach var="dict" items="${dictProductTypeList}">
                        <option value="${dict.code}">${dict.name}</option>
                    </c:forEach>
                </select>
                -
                ${claimVo.year}
                -
                <input type="text" style="width: 30px" id="notQualifiedReportCode_flowCode"
                       class="easyui-validatebox" data-options="required:true"/>
                <input type="hidden" name="notQualifiedReportCode" id="notQualifiedReportCode"/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.workshop"/>： </td>
            <td>
                <select name="workshopCode">
                    <c:forEach var="dict" items="${dictWorkshopList}">
                        <option value="${dict.code}">${dict.name}</option>
                    </c:forEach>
                </select>
            </td>
            <td align="right"><spring:message code="label.claim.find.place"/>：</td>
            <td>
                <select name="findPlace">
                    <c:forEach var="dict" items="${dictFindPlaceList}">
                        <option value="${dict.code}">${dict.name}</option>
                    </c:forEach>
                </select>
            </td>
            <td align="right"><spring:message code="label.claim.manage.body"/>： </td>
            <td>
                <select name="manageBody">
                    <c:forEach var="dict" items="${dictManageBodyList}">
                        <option value="${dict.code}">${dict.name}</option>
                    </c:forEach>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right"><span style="color:red;">*</span><spring:message code="label.claim.part.code"/>：</td>
            <td>
                <input type="hidden" id="partId" name="partId"/>
                <input type="text" id="partCode" onclick="dialogPart_();"
                       readonly class="easyui-validatebox" data-options="required:true"/>
            </td>
            <td align="right"><spring:message code="label.claim.part.name"/>：</td>
            <td>
                <input type="text" id="partName" disabled/>
            </td>
            <td align="right"><spring:message code="label.claim.drawing.code"/>：</td>
            <td>
                <input type="text" id="drawingCode" disabled/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.status"/>：</td>
            <td>
                <select name="claimStatus">
                    <c:forEach var="dict" items="${dictClaimStatusList}">
                        <option value="${dict.code}">${dict.name}</option>
                    </c:forEach>
                </select>
            </td>
            <td align="right"><spring:message code="label.claim.manufacture.date"/>：</td>
            <td>
                <input type="text" name="manufactureDate"
                       onFocus="WdatePicker({isShowWeek:true})" class="field Wdate"/>
            </td>
            <td align="right"><spring:message code="label.claim.delivery.batch.code"/>：</td>
            <td>
                <input type="text" name="deliveryBatchCode"/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.lot.size"/>：</td>
            <td>
                <input type="text" name="lotSize" class="easyui-numberbox" data-options="min:0,precision:0"/>
            </td>
            <td align="right"><span style="color:red;">*</span><spring:message code="label.claim.amount.not.qualified"/>：</td>
            <td>
                <input type="text" name="amountNotQualified" class="easyui-numberbox easyui-validatebox" data-options="min:0,precision:0,required:true"/>
            </td>
            <td align="right"><spring:message code="label.claim.claim.type"/>：</td>
            <td>
                <input id="typeT" type="radio" style="width: 10px" name="claimType" value="0" checked/><label for="typeT">Technical</label>
                <input id="typeL" type="radio" style="width: 10px" name="claimType" value="1"/><label for="typeL">Logistic</label>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.problem.desc"/>：</td>
            <td colspan="5">
                <input type="text" style="width: 350px;" name="problemDesc"/>
            </td>
        </tr>
    </table>
</fieldset>

<br/>
<table class="tableForm" width="100%">
    <tr>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>
            <input id="picture" name="picturePath" value="" type="hidden"  />
            <form action="${path}/business/ipic_system/claim/upImage.do" method="post" enctype="multipart/form-data" target="target">
                <spring:message code="label.claim.picture"/>：
                <input  type="file" name="fileUp" style="width: 250px" id="file"/>
                <br/>
                <br/>
                <div style="width:360px;height:150px;border:1.5px solid #C8D4EA;">
                    <img id="fileImg" src="#" alt="缺陷照片" style="width:360px;height:150px;">
                </div>
            </form>
            <div style="display: none;">
                <iframe id="target" name="target">
                </iframe>
            </div>
        </td>
    </tr>
</table>
<br/>
<table class="mytable" width="100%">
    <thead>
    <tr>
        <th data-options="field:'1',width:850">
            <spring:message code="label.claim.note"/>
        </th>
    </tr>
    </thead>
</table>
<br/>
<table class="tableForm mytable">
    <thead>
    <tr>
        <th data-options="field:'action',width:550"><spring:message code="table.head.claim.required.action"/></th>
        <th data-options="field:'date',width:160"><spring:message code="table.head.claim.date"/></th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td><spring:message code="label.claim.cs1"/></td>
        <td>
            <input type="text" name="cs1" onFocus="WdatePicker({isShowWeek:true})" value="" class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td><spring:message code="label.claim.cs2"/></td>
        <td>
            <input type="text" name="cs2" onFocus="WdatePicker({isShowWeek:true})" value="" class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td><spring:message code="label.claim.cs3"/></td>
        <td>
            <input type="text" name="cs3" onFocus="WdatePicker({isShowWeek:true})"
                   class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td><spring:message code="label.claim.cs4"/></td>
        <td>
            <input type="text" name="cs4" onFocus="WdatePicker({isShowWeek:true})"
                   class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td><spring:message code="label.claim.cs5"/></td>
        <td>
            <input type="text" name="cs5" onFocus="WdatePicker({isShowWeek:true})"
                   class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td><spring:message code="label.claim.cs6"/></td>
        <td>
            <input type="text" name="cs6" onFocus="WdatePicker({isShowWeek:true})"
                   class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td><spring:message code="label.claim.cs7"/></td>
        <td>
            <input type="text" name="cs7" onFocus="WdatePicker({isShowWeek:true})"
                   class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td><spring:message code="label.claim.cs8"/></td>
        <td>
            <input type="text" name="cs8" onFocus="WdatePicker({isShowWeek:true})"
                   class="field Wdate"/>
        </td>
    </tr>
    <tr>
        <td>
            <spring:message code="label.claim.cs9"/>
            <input id="typeDate" type="radio" style="width: 10px" name="cs9_" onclick="cs9_();"/><label for="typeDate">Date</label>
            <input id="typeNa" type="radio" style="width: 10px" name="cs9_" onclick="cs9_();" checked/><label for="typeNa">Na</label>
        </td>
        <td id="td_cs9">
        </td>
    </tr>
    </tbody>
</table>

<div class="tableForm">
    &nbsp;&nbsp;&nbsp;<spring:message code="label.claim.date"/>
</div>
<br />
<fieldset style="width:90%">
    <table class="tableForm" width="100%">
        <tr>
            <td align="right"><spring:message code="label.claim.affect.part"/>：</td>
            <td>
                <input style="width: 150px" name="affectParts"/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.comment"/>：</td>
            <td><input style="width: 150px" name="comment"/></td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.customer.claim.part"/> ：</td>
            <td>
                <input style="width: 150px" name="customerClaimPart"/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.supplier.accept.part"/>：</td>
            <td>
                <input style="width: 150px" name="supplierAcceptPart"/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.last.year.receive.part"/>：</td>
            <td>
                <input style="width: 150px" name="lastYearReceivePart"/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.ppms"/>：</td>
            <td>
                <input style="width: 150px" name="ppms"/>
            </td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.ppm.at.number"/>：</td>
            <td><input style="width: 150px" name="ppmAtNumber"/></td>
        </tr>
        <tr>
            <td align="right"><spring:message code="label.claim.closed"/>：</td>
            <td><input style="width: 150px" name="closed"/></td>
        </tr>
    </table>
</fieldset>
<br/>
<div id="operateDialog" class="easyui-dialog"
     data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">
    <iframe scrolling="auto" id='operateIFrame' frameborder="0"  src="" style="width:100%;height:100%;"/>
</div>
</body>
</html>